﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//求一个整数数组的最大值、最小值、平均值和所有数组元素的和
namespace ConsoleApp_b2
{
    class Program
    {
        static void Main(string[] args)
        {   
            Console.WriteLine("请输入数组中元素的个数：");
            int length=Convert.ToInt32(Console.ReadLine());
            int[] array = new int[length];
            Console.WriteLine("请输入数组中各元素的值：");
            for(int i = 0; i < length; i++)
            {
                 array[i] = Convert.ToInt32( Console.ReadLine());
            }
            int max =array[0];
            int min = array[0];
            int sum = 0;
            foreach (int n in array)
            {
                if (n < min) min = n;
                else max = n;
                sum += n;
            }
            double average = (double)sum / (double)length;
            Console.WriteLine("数组的最大值为："+max);
            Console.WriteLine("最小值为："+min);
            Console.WriteLine("平均值为："+average);
            Console.WriteLine("所有数组元素的和为："+sum);
            Console.Read();
        }
    }
}
